n,m=map(int,input().split())
MAP=[input().strip() for i in range(n)]
S=[[0]*(m+5) for i in range(n+5)]
for i in range(n):
for j in range(m):
if MAP[i][j]=="1":
S[i][j]=1
for i in range(1,n):
for j in range(m):
S[i][j]+=S[i-1][j]
for i in range(n):
for j in range(1,m):
S[i][j]+=S[i][j-1]
ANS=0
for i in range(n):
for j in range(m):
for k in range(i,n):
for l in range(j,m):
if S[k][l]-S[k][j-1]-S[i-1][l]+S[i-1][j-1]==0:
ANS=max(ANS,((k-i)+(l-j)+2)*2)
print(ANS)
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
string str[30];
bool boxHas(int startRow, int endRow, int startCol, int endCol)
{
for (int i = startRow; i <= endRow; i++)
{
for (int j = startCol; j <= endCol; j++)
{
if (str[i][j] == '1') return true;
}
}
return false;
}
int main()
{
int n, m; cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> str[i];
}
int ans = 0;
for (int startRow = 0; startRow < n; startRow++)
{
for (int endRow = startRow; endRow < n; endRow++)
{
for (int startCol = 0; startCol < m; startCol++)
{
for (int endCol = startCol; endCol < m; endCol++)
{
if (boxHas(startRow, endRow, startCol, endCol)) {
continue;
}
ans = max(ans, (endRow - startRow + 1) * 2 + (endCol - startCol + 1) * 2);
}
}
}
}
cout << ans << endl;
}
822B - Crossword solving | 1623A - Robot Cleaner |
884B - Japanese Crosswords Strike Back | 862B - Mahmoud and Ehab and the bipartiteness |
429A - Xor-tree | 1675C - Detective Task |
950A - Left-handers Right-handers and Ambidexters | 672B - Different is Good |
1C - Ancient Berland Circus | 721A - One-dimensional Japanese Crossword |
1715B - Beautiful Array | 60B - Serial Time |
453A - Little Pony and Expected Maximum | 1715A - Crossmarket |
1715C - Monoblock | 1512C - A-B Palindrome |
1679B - Stone Age Problem | 402A - Nuts |
792A - New Bus Route | 221A - Little Elephant and Function |
492C - Vanya and Exams | 1369B - AccurateLee |
892B - Wrath | 999A - Mishka and Contest |
727C - Guess the Array | 1625C - Road Optimization |
1715D - 2+ doors | 267A - Subtractions |
1582A - Luntik and Concerts | 560A - Currency System in Geraldion |